/*
 * License: Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved.
 * Description: translation data defination
 * Date: 2019-11-30 11:00:52
 * LastEditTime : 2020-02-19 17:38:34
 */
#ifndef TRANS_DATA_H
#define TRANS_DATA_H

#include <string>
#include "hiaiengine/data_type.h"
#include "hiaiengine/data_type_reg.h"

using namespace std;

extern vector<string> g_videos;
extern vector<string> g_pushStreams;

struct TransData {
    int graphId;
    int deviceId;
    int channelId;
    uint64_t frameId;

    int outputFormat;  // D1:0, CIF:1
    int videoFormat;   // video format, .h264 or .h265

    int vencFrameRate;
    int vencBitRate;
    int vencCtlType;
    int eos;

    // packetData
    float streamPullFps;

    // decode
    float curDecodeFps;

    // encode
    float curEncodeFps;

    // data
    uint32_t width;
    uint32_t height;
    uint32_t alignWidth;
    uint32_t alignHeight;
    shared_ptr<uint8_t> buf;
    uint32_t len;

    // if output stream is connected
    uint32_t isOutputConnected;
};
template<class Archive>
void serialize(Archive& ar, TransData& td)
{
    ar(td.graphId);
    ar(td.deviceId);
    ar(td.channelId);
    ar(td.frameId);
    ar(td.outputFormat);
    ar(td.videoFormat);
    ar(td.vencFrameRate);
    ar(td.vencBitRate);
    ar(td.vencCtlType);
    ar(td.eos);
    ar(td.streamPullFps);
    ar(td.curDecodeFps);
    ar(td.curEncodeFps);
    ar(td.width);
    ar(td.height);
    ar(td.alignWidth);
    ar(td.alignHeight);
    ar(td.len);
    ar(td.isOutputConnected);

    if (td.len > 0 && td.buf.get() == nullptr) {
        td.buf.reset(new uint8_t[td.len], [](uint8_t *p) {delete [] p;});
    }
    ar(cereal::binary_data(td.buf.get(), td.len * sizeof(uint8_t)));
}

#define USE_DEFINE_ERROR 0x6001
enum { HIAI_IDE_ERROR_CODE, HIAI_IDE_INFO_CODE, HIAI_IDE_WARNING_CODE };
HIAI_DEF_ERROR_CODE(USE_DEFINE_ERROR, HIAI_ERROR, HIAI_IDE_ERROR, "");
HIAI_DEF_ERROR_CODE(USE_DEFINE_ERROR, HIAI_INFO, HIAI_IDE_INFO, "");
HIAI_DEF_ERROR_CODE(USE_DEFINE_ERROR, HIAI_WARNING, HIAI_IDE_WARNING, "");

enum OutputFormat { D1, CIF };

#endif  // TRANS_DATA_H
